package org.beholder;

import org.apache.commons.io.IOUtils;
import org.apache.log4j.Logger;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

/**
 * Created with IntelliJ IDEA.
 * User: ddreval
 * Date: 18.10.12
 * Time: 14:05
 * To change this template use File | Settings | File Templates.
 */
public class ThumbnailServlet extends AbstractServlet {

	Logger logger = Logger.getLogger(ImageServlet.class);

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    	String id = req.getParameter("id");
    	InputStream is = getThumbStream(id);
    	OutputStream os = resp.getOutputStream();
    	IOUtils.copy(is, os);
    	IOUtils.closeQuietly(is);
    	IOUtils.closeQuietly(os);
        closeResources();
    }

}